package com.runda.controller.delivery;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bbjob.dto.Result;
import com.bbjob.mapper.ExamineeInfoMapper;
import com.bbjob.mapper.SysOrganizationMapper;
import com.bbjob.mapper.SysOrganizationStuMapper;
import com.bbjob.model.ExamineeInfo;
import com.github.pagehelper.PageInfo;
import com.runda.query.QueryExaminee;
import com.runda.service.IExamineeInfoService;

@Api(tags="examineeInfoApi-delivery", description="应试人员管理(分发中心用绕过登录)")
@RestController
@RequestMapping(path="delivery/examineeinfo", produces="application/json;charset=utf-8")
public class DeliveryExamineeInfoController {
	
	@Resource
	private IExamineeInfoService examineeInfoService;

	@Resource
	private SysOrganizationMapper sysOrganizationMapper;
	
	@Resource
	private SysOrganizationStuMapper sysOrganizationStuMapper;
	
	@Resource
	private ExamineeInfoMapper examineeInfoMapper;
	
	@ApiOperation(value="应试人员录入", notes="应试人员考生录入")
	@ApiImplicitParam(name="examineeInfo", value="应试人员录入", required=true, dataType="ExamineeInfo")
	@RequestMapping(value="entry", method=RequestMethod.POST)
	public Result entryExaminee(@RequestBody ExamineeInfo examineeInfo) {
		
		return examineeInfoService.entry(examineeInfo);
	}

	
	@ApiOperation(value="应试人员列表", notes="应试人员列表")
	@ApiImplicitParam(name="examinee", value="应试人员信息", required=true, dataType="QueryExaminee")
	@RequestMapping(value="list", method=RequestMethod.POST)
	public Result list(@RequestBody QueryExaminee examinee) {
		
		List<ExamineeInfo> data = examineeInfoService.selectByParams(examinee);
		PageInfo<ExamineeInfo> pageInfo = new PageInfo<ExamineeInfo>(data);
		
		return new Result(pageInfo);
	}
	
	
	@ApiOperation(value="应试人员信息", notes="应试人员信息")
	@ApiImplicitParam(name="id", value="应试人员信息id", required=true, dataType="Integer", paramType="path")
	@RequestMapping(value="get/{id}", method=RequestMethod.GET)
	public Result get(@PathVariable("id")Integer id) {
		
		return new Result(examineeInfoService.selectByKey(id));
	}
	
	@ApiOperation(value="修改应试人员信息", notes="修改应试人员信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name="id", value="应试人员信息id", required=true, dataType="Integer", paramType="path"),
			@ApiImplicitParam(name="examineeInfo", value="应试人员信息", required=true, dataType="ExamineeInfo")	
	})
	@RequestMapping(value="edit/{id}", method=RequestMethod.POST)
	public Result edit(@PathVariable("id")Integer id, @RequestBody ExamineeInfo examineeInfo) {
		
		examineeInfo.setId(id);
		examineeInfo.setUpdateTime(new Date());
		
		return examineeInfoService.updateDistByEno(examineeInfo);
	}
		
	@ApiOperation(value="删除考生信息", notes="删除考生信息")
	@ApiImplicitParam(name="id", value="考生信息id", required=true, dataType="Integer", paramType="path")
	@RequestMapping(value="del/{id}", method=RequestMethod.GET)
	public Result del(@PathVariable("id")Integer id) {
		
		examineeInfoService.delete(id);
		
		return new Result();
	}
}
